<!-- Uniapp + TypeScript 相关配置文档 -->
<!-- https://www.jianshu.com/p/b01b5158cfe0 -->

<!-- vue-cli创建uniapp项目报错[ app.json 文件内容错误] app.json: app.json 未找到 -->
<!-- https://blog.csdn.net/weixin_46016926/article/details/119334939 -->

<template>
	<view class="content">
		<view class="content">
			<image v-if="imgSrc" class="enterBg" mode="aspectFill" :src='imgSrc'></image>

			<video v-if="videoSrc" :src="videoSrc" autoplay="true" loop="true" controls="false"
			 enable-progress-gesture="false" object-fit="cover"></video>

			<div class="bottom-info">
				<button form-type='submit' @click="goIndex" class="button" value="点 击 开 启">点 击 开 启(uni)</button>
				<view class="support">深圳银创网络科技提供技术支持</view>
			</div>
		</view>
	</view>
</template>



<script lang='ts'>
	import {
		Component,
		Vue
	} from 'vue-property-decorator';


	import {
		Car,
		loggingIdentity,
		mySearch,
		CreateArrayFunc,
		CreateArrayFunc22
	} from '../../utils/interfaces';


	const mdCode = require('../../utils/md5.js');
	const desCode = require('../../utils/aesUtil.js');
	const api_js = require("../../utils/api.js");
	var app = getApp();


	// 一定要加 @Component 装饰器，否则小程序生命周期会报错失效
	@Component({})

	export default class App extends Vue {
		// 初始化数据
		// 公共public，私有private与受保护protected的修饰符
		// 一般来说，在TypeScript里，成员都默认为public。
		title: string = 'Hello';
		imgSrc: string = '';
		videoSrc: string = '';

		onLoad() {
			//变量a被类型推断为number
			let globalData: any = app.globalData as object;
			globalData.HeadPortrait = "https://imgm.gmw.cn/attachement/jpg/site215/20210917/4159435567306654605.jpg";
			console.log(app.globalData, "app");

			this.init();
		}
		//计算属性
		get age(): string {
			return this.title + 1
		}

		init() {
			let wMsgID = desCode.wMsgID();
			// let wParam = desCode.to3des();
			let wParam = '';
			let md = mdCode.hexMD5('8888' + '100' + wMsgID + wParam + 'q1w2e3r4t5y6');
			const data = {
				wAgent: 8888,
				wAction: 100,
				wMsgID: wMsgID,
				wParam: wParam,
				wSign: md,
				wImei: 222,
				wVersion: 2,
				wRequestUserID: 4
			}
			api_js.postReq(data, (res: any) => {
				console.log(res, "数据")
				if (res.ReturnCode == 0) {
					if (res.Data[0].categorykey == '1') {
						this.imgSrc = res.Data[0].logo;
					} else if (res.Data[0].categorykey == '2') {
						this.videoSrc = res.Data[0].logo;
					}
				}
			});
		}
		
		
					goIndex() {
						console.log(112)
						uni.switchTab({
							url: `../index/index`
						})
					}



	}
</script>



<style lang="scss" scoped>
	@import 'index.scss';
</style>
